﻿Imports System
Imports System.Collections.Generic

Namespace System.Workflow.ComponentModel
    Friend Class ItemListChangeEventArgs([Of] T)
        Inherits EventArgs
        ' Methods
        Public Sub New(ByVal index As Integer, ByVal removedItems As ICollection([Of] T), ByVal addedItems As ICollection([Of] T), ByVal owner As Object, ByVal action As ItemListChangeAction)
            Me.action = ItemListChangeAction.Add
            Me.index = index
            Me.removedItems = removedItems
            Me.addedItems = addedItems
            Me.action = action
            Me.owner = owner
        End Sub

        Public Sub New(ByVal index As Integer, ByVal removedActivity As T, ByVal addedActivity As T, ByVal owner As Object, ByVal action As ItemListChangeAction)
            Me.action = ItemListChangeAction.Add
            Me.index = index
            If (Not removedActivity Is Nothing) Then
                Me.removedItems = New List([Of] T)
                DirectCast(Me.removedItems, List([Of] T)).Add(removedActivity)
            End If
            If (Not addedActivity Is Nothing) Then
                Me.addedItems = New List([Of] T)
                DirectCast(Me.addedItems, List([Of] T)).Add(addedActivity)
            End If
            Me.action = action
            Me.owner = owner
        End Sub


        ' Properties
        Public ReadOnly Property Action As ItemListChangeAction
            Get
                Return Me.action
            End Get
        End Property

        Public ReadOnly Property AddedItems As IList([Of] T)
            Get
                If (Me.addedItems Is Nothing) Then
                    Return New List([Of] T)().AsReadOnly
                End If
                Return New List([Of] T)(Me.addedItems).AsReadOnly
            End Get
        End Property

        Public ReadOnly Property Index As Integer
            Get
                Return Me.index
            End Get
        End Property

        Public ReadOnly Property Owner As Object
            Get
                Return Me.owner
            End Get
        End Property

        Public ReadOnly Property RemovedItems As IList([Of] T)
            Get
                If (Me.removedItems Is Nothing) Then
                    Return New List([Of] T)().AsReadOnly
                End If
                Return New List([Of] T)(Me.removedItems).AsReadOnly
            End Get
        End Property


        ' Fields
        Private action As ItemListChangeAction
        Private addedItems As ICollection([Of] T)
        Private index As Integer
        Private owner As Object
        Private removedItems As ICollection([Of] T)
    End Class
End Namespace

